package com.itbaizhan.openhis.controller;

import com.itbaizhan.openhis.dto.DictTypeDto;
import com.itbaizhan.openhis.service.DictTypeService;
import com.itbaizhan.openhis.vo.AjaxResult;
import com.itbaizhan.openhis.vo.DataGridView;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 查询字典类型
 */
@RestController
@RequestMapping("system/dict/type")
@Slf4j
public class DictTypeController {
	
	@Autowired
	private DictTypeService dictTypeService;
	
	/**
	 * 查询字典类型分页数据
	 * @param dictTypeDto
	 * @return
	 */
	@GetMapping("listForPage")
	public AjaxResult listForPage(DictTypeDto dictTypeDto){
		log.info("查询字典类型分页数据，参数：{}",dictTypeDto);
		DataGridView dataGridView =dictTypeService.listForPage(dictTypeDto);
		return AjaxResult.success("查询成功", dataGridView.getData(),  dataGridView.getTotal());
	}
	
	/**
	 * 同步缓存字典数据
	 * @return
	 */
	@GetMapping("dictCacheAsync")
	public AjaxResult dictCacheAsync(){
		log.info("开始异步缓存字典数据");
		dictTypeService.dictCacheAsync();
		return AjaxResult.success();
	}
}
